package org.hxzon.tapestry5.coercion;

import java.util.Collection;

import org.apache.tapestry5.ioc.services.Coercion;
import org.hxzon.tapestry5.model.ValueIsSelected;

public class CollectionToValueIsSelectedCoercion implements Coercion<Collection<Object>, ValueIsSelected<Object>> {

    public ValueIsSelected<Object> coerce(final Collection<Object> input) {
        ValueIsSelected<Object> result = new ValueIsSelected<Object>() {

            @Override
            public boolean isSelected(Object value) {
                return input.contains(value);
            }

        };
        return result;
    }
}
